import bus from '@/bus'
import { preFixPath }  from '@/util'
const getFullUrl = (path) => {
  return path && path.indexOf('http') > -1 ? path : preFixPath + path
}
let data = {
    status: 'pass',
    totalItem: 1,
    pageSize: window.$pageSize,
    currentPage: 1,
    columns: [{
        title: '标签名称',
        key: 'name',
        align: 'left',
        minWidth: 200
    }, {
        title: '标签配图',
        key: 'productImage',
        align: 'left',
        minWidth: 150,
        renderHeader: (h) => {
          let oDiv = h('div', [
            h('span', '标签配图'),
            h('Icon', {
              props: {
                type: 'ios-help-circle'
              }
            })
          ])
          return h('Tooltip', {
            style: {
              cursor: 'pointer'
            },
            props: {
              transfer: true,
              placement: 'top',
              content: '这个配图会显示在商品详情页的商品主图上',
              maxWidth: '200'
            }
          }, [oDiv])
        },
        render:(h, params) => {
            return h('a', {
                attrs: { 
                    href: getFullUrl(params.row.productImage),
                    target: '_blank' 
                } 
            }, [h('img', {
                attrs: {
                  src: getFullUrl(params.row.productImage + '_100w')
                },
                style: {
                  'width': '40px',
                  'height': '40px',
                  'margin-top': '5px'
                }
            })])
        }
    }, {
        title: '标签图标',
        key: 'headImage',
        align: 'left',
        minWidth: 150,
        renderHeader: (h) => {
          let oDiv = h('div', [
            h('span', '标签图标'),
            h('Icon', {
              props: {
                type: 'ios-help-circle'
              }
            })
          ])
          return h('Tooltip', {
            style: {
              cursor: 'pointer'
            },
            props: {
              transfer: true,
              placement: 'top',
              content: '这个图标会显示在商品详情页的“放心购”区域点开来的页面上',
              maxWidth: '200'
            }
          }, [oDiv])
        },
        render:(h, params) => {
            return h('a', {
                attrs: { 
                    href:  getFullUrl(params.row.headImage),
                    target: '_blank' 
                } 
            }, [h('img', {
                attrs: {
                  src:  getFullUrl(params.row.headImage + '_100w')
                },
                style: {
                  'width': '40px',
                  'height': '40px',
                  'margin-top': '5px'
                }
            })])
        }
    }, {
        title: '操作',
        align: 'right',
        minWidth: 160,
        render:(h,params) => {
            return h('div',[
                h('Button', {
                    class: 'mr',
                    props:{
                        size:'small',
                        type:'primary'
                    },
                    on: {
                        click: () => {
                            bus.$emit('onEdit', params.row.id)
                        }
                    }
                }, '编辑'),
                h('Button', {
                    props:{
                        size:'small',
                        type: 'warning'
                    },
                    on: {
                        click: () => {
                            bus.$emit('onDelete', params.row.id, params.row.name, params.index)
                        }
                    }
                }, '删除')
            ])
        }
    }],
    data: []
}
export default data